package com.evry.marshallingtest.support;

import org.springframework.stereotype.Service;

import com.evry.marshallingtest.newmodel.Customer;
import com.evry.marshallingtest.newmodel.Database;

@Service("dataFinder")
public class DataFinder {
	
	/**
	 * Searches through customers in the new model, and returns the first found matching the provided personal code number
	 * 
	 * @param personalCodeNumber the personal code number of the customer to search for
	 * @return the first customer with matching personal code number, or null if none is found
	 */
	public Customer findCustomerWithPersonalCodeNumber(Database database, String personalCodeNumber) {	
		for(Customer customer : database.getCustomers().getCustomer()){
			if (customer.getPersonalCodeNumber().equals(personalCodeNumber)){
				return customer;
			}
		}
		return null;
	}
}
